package com.yx.ecglineview;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

import com.yx.ecglineview.customview.BrokenLineView;


/**
 * Created : Yx
 * Time : 2018/11/8 16:43
 * Describe :折线图2(折线1衍生品)
 */
public class BloodData2Activity extends AppCompatActivity {
    private TextView tv_left;
    private TextView blood_day;
    private TextView blood_week;
    private TextView blood_month;

    private BrokenLineView blv_blood;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_blood_data2);
        tv_left = (TextView) findViewById(R.id.tv_left);
        blood_day = (TextView) findViewById(R.id.blood_day);
        blood_week = (TextView) findViewById(R.id.blood_week);
        blood_month = (TextView) findViewById(R.id.blood_month);
        blv_blood = (BrokenLineView) findViewById(R.id.blv_blood);
        tv_left.setOnClickListener(clicks);
        blood_day.setOnClickListener(clicks);
        blood_week.setOnClickListener(clicks);
        blood_month.setOnClickListener(clicks);


        inItData();
    }

    private void inItData() {
        blv_blood.setDatas(null);
    }

    private View.OnClickListener clicks = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            switch (v.getId()) {
                case R.id.tv_left:
                    finish();
                    break;
                case R.id.blood_day://日
                    setStyle(blood_day);
                    break;
                case R.id.blood_week://周
                    setStyle(blood_week);
                    break;
                case R.id.blood_month://月
                    setStyle(blood_month);
                    break;
            }
        }
    };

    private void setStyle(TextView textView) {
        blood_day.setTextColor(ContextCompat.getColor(this, R.color.llqaff));
        blood_week.setTextColor(ContextCompat.getColor(this, R.color.llqaff));
        blood_month.setTextColor(ContextCompat.getColor(this, R.color.llqaff));
        blood_day.setBackgroundColor(ContextCompat.getColor(this, R.color.colorWhite));
        blood_week.setBackgroundColor(ContextCompat.getColor(this, R.color.colorWhite));
        blood_month.setBackgroundColor(ContextCompat.getColor(this, R.color.colorWhite));
        textView.setTextColor(ContextCompat.getColor(this, R.color.colorWhite));
        textView.setBackgroundColor(ContextCompat.getColor(this, R.color.llqaff));

    }

}
